package views.inventory;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.border.BevelBorder;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionListener;
import javax.swing.JSeparator;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public class PrintBarCode extends JPanel
{
	private JTextField tfPurchasePrice;
	private JTextField tfmrp;
	private JTextField tfQuantity;
	private JComboBox cbSize;
	private JComboBox cbColor;
	private JButton btnPrintBarcode;
	private JButton btnAddStock;
	private JComboBox cbSellerName;
	private JComboBox cbCategoryName;
	private JButton btnAddMaterial;
	private JTable table;
	private JTextField tfTotal;
	private JLabel lblDate;
	private JTextField tfDate;
	private JButton btnCl;
	private JButton btnClear;

	public PrintBarCode() 
	{
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		setPreferredSize(new Dimension(615, 353));
		setSize(350, 550);
		this.setMinimumSize(new Dimension(350, 550));
		this.setBackground(new Color(239,239,239));
		this.setMaximumSize(new Dimension(350, 550));
		this.setBackground(new Color(239,239,239));
		
		JLabel lblSellerName = new JLabel("Seller Name");
		springLayout.putConstraint(SpringLayout.NORTH, lblSellerName, 20, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblSellerName, 20, SpringLayout.WEST, this);
		lblSellerName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblSellerName);
		
		cbSellerName = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, cbSellerName, 6, SpringLayout.SOUTH, lblSellerName);
		springLayout.putConstraint(SpringLayout.WEST, cbSellerName, 0, SpringLayout.WEST, lblSellerName);
		cbSellerName.setPreferredSize(new Dimension(200, 20));
		cbSellerName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		add(cbSellerName);
		
		JLabel lblCategoryName = new JLabel("Category Name");
		springLayout.putConstraint(SpringLayout.NORTH, lblCategoryName, 20, SpringLayout.SOUTH,cbSellerName);
		springLayout.putConstraint(SpringLayout.WEST, lblCategoryName, 0, SpringLayout.WEST, lblSellerName);
		lblCategoryName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblCategoryName);
		
		cbCategoryName = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, cbCategoryName, 6, SpringLayout.SOUTH, lblCategoryName);
		springLayout.putConstraint(SpringLayout.WEST, cbCategoryName, 0, SpringLayout.WEST, lblSellerName);
		cbCategoryName.setPreferredSize(new Dimension(200, 20));
		cbCategoryName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		add(cbCategoryName);
		
		JLabel lblQuantity = new JLabel("Quantity");
		springLayout.putConstraint(SpringLayout.NORTH, lblQuantity, 20, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblQuantity, 20, SpringLayout.EAST,cbSellerName);
		lblQuantity.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblQuantity);
		
		tfQuantity = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfQuantity, 6, SpringLayout.SOUTH, lblQuantity);
		springLayout.putConstraint(SpringLayout.WEST, tfQuantity, 0, SpringLayout.WEST,lblQuantity);
		tfQuantity.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		add(tfQuantity);
		tfQuantity.setPreferredSize(new Dimension(115, 23));
		
		JLabel lblPurchasePrice = new JLabel("Purchase Price");
		springLayout.putConstraint(SpringLayout.NORTH, lblPurchasePrice, 20, SpringLayout.SOUTH, tfQuantity);
		springLayout.putConstraint(SpringLayout.WEST, lblPurchasePrice, 0, SpringLayout.WEST, lblQuantity);
		lblPurchasePrice.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblPurchasePrice);
		
		tfPurchasePrice = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfPurchasePrice, 6, SpringLayout.SOUTH, lblPurchasePrice);
		springLayout.putConstraint(SpringLayout.WEST, tfPurchasePrice, 0, SpringLayout.WEST, lblPurchasePrice);
		tfPurchasePrice.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		add(tfPurchasePrice);
		tfPurchasePrice.setColumns(10);
		
		JLabel lblSize = new JLabel("Size");
		springLayout.putConstraint(SpringLayout.WEST, lblSize, 20, SpringLayout.EAST,tfQuantity);
		springLayout.putConstraint(SpringLayout.NORTH, lblSize, 0, SpringLayout.NORTH,lblQuantity);
		lblSize.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblSize);
		
		cbSize = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, cbSize, 6, SpringLayout.SOUTH, lblSize);
		springLayout.putConstraint(SpringLayout.WEST, cbSize, 0, SpringLayout.WEST, lblSize);
		cbSize.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		add(cbSize);
		cbSize.setPreferredSize(new Dimension(115, 23));
		
		JLabel lblColor = new JLabel("Color");
		springLayout.putConstraint(SpringLayout.NORTH, lblColor, 0, SpringLayout.NORTH,lblPurchasePrice);
		springLayout.putConstraint(SpringLayout.WEST, lblColor, 0, SpringLayout.WEST,lblSize);
		lblColor.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblColor);
		
		cbColor = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, cbColor, 6, SpringLayout.SOUTH, lblColor);
		springLayout.putConstraint(SpringLayout.WEST, cbColor, 0, SpringLayout.WEST, lblColor);
		cbColor.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		add(cbColor);
		cbColor.setPreferredSize(new Dimension(115, 23));
		
		JLabel lblMrp = new JLabel("MRP");
		springLayout.putConstraint(SpringLayout.NORTH, lblMrp, 0, SpringLayout.NORTH,lblSize);
		springLayout.putConstraint(SpringLayout.WEST, lblMrp, 20, SpringLayout.EAST,cbSize);
		lblMrp.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblMrp);
		
		tfmrp = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfmrp, 6, SpringLayout.SOUTH, lblMrp);
		springLayout.putConstraint(SpringLayout.WEST, tfmrp, 0, SpringLayout.WEST,lblMrp);
		tfmrp.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		add(tfmrp);
		tfmrp.setColumns(10);
		
		btnAddMaterial = new JButton("Add Material");
		btnAddMaterial.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, btnAddMaterial, 0, SpringLayout.NORTH, cbCategoryName);
		springLayout.putConstraint(SpringLayout.WEST, btnAddMaterial, 0, SpringLayout.WEST, lblMrp);
		add(btnAddMaterial);
		btnAddMaterial.setActionCommand("add material");
		
		JSeparator separator = new JSeparator();
		springLayout.putConstraint(SpringLayout.NORTH, separator, 20, SpringLayout.SOUTH, cbCategoryName);
		springLayout.putConstraint(SpringLayout.WEST, separator, 20, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, separator, -20, SpringLayout.EAST, this);
		add(separator);
		
		btnPrintBarcode = new JButton("Print Barcode");
		btnPrintBarcode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.WEST, btnPrintBarcode, 20, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, btnPrintBarcode, -10, SpringLayout.SOUTH, this);
		add(btnPrintBarcode);
		btnPrintBarcode.setActionCommand("print barcode");
		
		btnAddStock = new JButton("Add Stock");
		btnAddStock.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, btnAddStock, 0, SpringLayout.NORTH, btnPrintBarcode);
		springLayout.putConstraint(SpringLayout.WEST, btnAddStock, 20, SpringLayout.EAST, btnPrintBarcode);
		add(btnAddStock);
		btnAddStock.setActionCommand("add stock");
		
		JScrollPane scrollPane = new JScrollPane();
		springLayout.putConstraint(SpringLayout.NORTH, scrollPane, 20, SpringLayout.SOUTH, separator);
		springLayout.putConstraint(SpringLayout.WEST, scrollPane, 20, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, scrollPane, -20, SpringLayout.EAST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, scrollPane, -10, SpringLayout.NORTH, btnPrintBarcode);
		add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Sr.No.", "Seller Name", "Category", "Size", "Color", "Purchase Price", "Quantity", "MRP", "Delete"
			}
		));
		scrollPane.setViewportView(table);
		
		tfTotal = new JTextField();
		tfTotal.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfTotal, 0, SpringLayout.NORTH,btnAddMaterial);
		springLayout.putConstraint(SpringLayout.EAST, tfTotal, -20, SpringLayout.EAST, this);
		add(tfTotal);
		tfTotal.setColumns(10);
		
		JLabel lblTotal = new JLabel("Total");
		lblTotal.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.WEST, lblTotal, 0, SpringLayout.WEST, tfTotal);
		springLayout.putConstraint(SpringLayout.SOUTH, lblTotal, 0, SpringLayout.SOUTH, lblCategoryName);
		add(lblTotal);
		
		lblDate = new JLabel("Date");
		lblDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblDate, 0, SpringLayout.NORTH, lblSellerName);
		springLayout.putConstraint(SpringLayout.WEST, lblDate, 20, SpringLayout.EAST, tfmrp);
		add(lblDate);
		
		tfDate = new JTextField();
		tfDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, tfDate, 6, SpringLayout.SOUTH, lblDate);
		springLayout.putConstraint(SpringLayout.WEST, tfDate, 0, SpringLayout.WEST, lblDate);
		add(tfDate);
		tfDate.setColumns(10);
		
		btnCl = new JButton("Cl");
		btnCl.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, btnCl, 0, SpringLayout.NORTH, tfDate);
		springLayout.putConstraint(SpringLayout.WEST, btnCl, 6, SpringLayout.EAST, tfDate);
		add(btnCl);
		btnCl.setActionCommand("cl");
		
		btnClear = new JButton("Clear");
		btnClear.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, btnClear, 0, SpringLayout.NORTH, cbCategoryName);
		springLayout.putConstraint(SpringLayout.WEST, btnClear, 0, SpringLayout.WEST, lblDate);
		add(btnClear);
		btnClear.setActionCommand("clear");
	}
	/************************************************************/
	public void addActionListenerOnButtons(ActionListener al)
	{
		btnPrintBarcode.addActionListener(al);
		btnAddMaterial.addActionListener(al);
		btnAddStock.addActionListener(al);
		btnCl.addActionListener(al);
		btnClear.addActionListener(al);
	}
	/************************************************************/
	public JTextField gettPrice() {
		return tfPurchasePrice;
	}
	public void settPrice(JTextField tPrice) {
		this.tfPurchasePrice = tPrice;
	}
	public JTextField getTmrp() {
		return tfmrp;
	}
	public void setTmrp(JTextField tmrp) {
		this.tfmrp = tmrp;
	}
	public void setTfPrice(JTextField tfPrice) {
		this.tfPurchasePrice = tfPrice;
	}
	public JTextField getTfmrp() {
		return tfmrp;
	}
	public void setTfmrp(JTextField tfmrp) {
		this.tfmrp = tfmrp;
	}
	public JTextField getTfQuantity() {
		return tfQuantity;
	}
	public void setTfQuantity(JTextField tfQuantity) {
		this.tfQuantity = tfQuantity;
	}
	public JComboBox getCbSize() {
		return cbSize;
	}
	public void setCbSize(JComboBox cbSize) {
		this.cbSize = cbSize;
	}
	public JComboBox getCbColor() {
		return cbColor;
	}
	public void setCbColor(JComboBox cbColor) {
		this.cbColor = cbColor;
	}
	public JButton getBtnPrintBarcode() {
		return btnPrintBarcode;
	}
	public void setBtnPrintBarcode(JButton btnPrintBarcode) {
		this.btnPrintBarcode = btnPrintBarcode;
	}
	public JButton getBtnAddStock() {
		return btnAddStock;
	}
	public void setBtnAddStock(JButton btnAddStock) {
		this.btnAddStock = btnAddStock;
	}	
	public JTextField getTfPurchasePrice() {
		return tfPurchasePrice;
	}
	public void setTfPurchasePrice(JTextField tfPurchasePrice) {
		this.tfPurchasePrice = tfPurchasePrice;
	}
	public JComboBox getCbSellerName() {
		return cbSellerName;
	}
	public void setCbSellerName(JComboBox cbSellerName) {
		this.cbSellerName = cbSellerName;
	}
	public JComboBox getCbCategoryName() {
		return cbCategoryName;
	}
	public void setCbCategoryName(JComboBox cbCategoryName) {
		this.cbCategoryName = cbCategoryName;
	}
	public JButton getBtnAddMaterial() {
		return btnAddMaterial;
	}
	public void setBtnAddMaterial(JButton btnAddMaterial) {
		this.btnAddMaterial = btnAddMaterial;
	}
	public JTable getTable() {
		return table;
	}
	public void setTable(JTable table) {
		this.table = table;
	}
	public JTextField getTfTotal() {
		return tfTotal;
	}
	public void setTfTotal(JTextField tfTotal) {
		this.tfTotal = tfTotal;
	}
	public JTextField getTfDate() {
		return tfDate;
	}
	public void setTfDate(JTextField tfDate) {
		this.tfDate = tfDate;
	}
	public JButton getBtnCl() {
		return btnCl;
	}
	public void setBtnCl(JButton btnCl) {
		this.btnCl = btnCl;
	}
}
